import axios from '@/api/api'

// 为以后可能要加上请求前缀需要，直接在这里改就行了
let base = '';

// 表单登录
export const postForm = (url, data) => {
    return axios({
        method: 'post',
        url: `${base}${url}`,
        data: data,
        transformRequest: [function (data) {
            let ret = '';
            for (let i in data) {
                ret += encodeURIComponent(i) + '=' + encodeURIComponent(data[i]) + '&'
            }
            return ret;
        }],
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
}

export const postRequest = (url, data) => {
    return axios({
        method: 'post',
        url: `${base}${url}`,
        data: data
    })
}


export const putRequest = (url, data) => {
    return axios({
        method: 'put',
        url: `${base}${url}`,
        data: data
    })
}
export const getRequest = (url, params) => {
    return axios({
        method: 'get',
        url: `${base}${url}`,
        params: params
    })
}
export const deleteRequest = (url, id) => {
    return axios({
        method: 'delete',
        url: `${base}${url}/${id}`
    })
}
